<%-- 
    Document   : risultatoRicerca
    Created on : 9-ago-2010, 15.33.04
    Author     : edoardo
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	try {
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<table>
	<tr>
		<c:if test="${loginForm.utenti.profilo.descrizione=='USER'}">
			<td><a href="inserisciTicket.do">Inserisci ticket</a></td>
		</c:if>
		<td><a href="esci.do">Esci</a></td>
	</tr>
</table>
<c:if test="${loginForm.utenti.profilo.descrizione=='DEVELOPER' }">
	<form action="search.do" method="post" >
	<table border="0">
		<tr>
			<td><select name="searchByProject">
				<option value="-1" >--Seleziona filtro--</option>
				<c:forEach items="${progettiUtente}" var="item">
					<option value="<c:out value="${item.idProgetto}"/>"
						<c:if test="${item.idProgetto==param.searchByProject}">selected="selected"</c:if>><c:out
						value="${item.descrizione}" /></option>
				</c:forEach>
			</select></td>
			<td><select name="searchByStato">
				<option value="-1" >--Seleziona filtro--</option>
				<c:forEach items="${stati}" var="item">
					<option value="<c:out value="${item.stati.idStato}"/>"
						<c:if test="${item.stati.idStato==param.searchByStato}">selected="selected"</c:if>><c:out
						value="${item.stati.descrizione}" /></option>
				</c:forEach>
				
			</select></td>
			<td><input type="submit" name="filtraTicket" value="Applica filtro"/></td>
		</tr>

	</table>
	</form>
</c:if>


<c:choose>

	<c:when test="${not empty risultatoRicercaTicket}">
		<table width="100%">
			<tr style="border-bottom: thin">
				<td>ID</td>
				<td>TITOLO</td>
				<td>DATA INSERIMENTO</td>
				<td>STATO</td>
				<td>UTENTE</td>
				<td>DATA ULTIMA MODIFICA</td>
				<td>UTENTE ULTIMA MODIFICA</td>
				<td>OWNER</td>
				<td>ALLEGATI</td>
			</tr>

			<c:forEach items="${risultatoRicercaTicket}" var="item">
				<tr>
					<td><a
						href="inserisciTicket.do?idTicket=<c:out value="${item.tickets.idTicket}"/>"><c:out
						value="${item.tickets.idTicket}" /></a></td>
					<td><a
						href="search.do?id=<c:out value="${item.tickets.idTicket}" />&showDesc=true&p=<c:out value="${currentPage.page }" />"><c:out
						value="${item.tickets.titoloTicket}" /></a></td>
					<td><fmt:formatDate pattern="dd/MM/yyyy"
						value="${item.tickets.dataInserimento}" /></td>
					<td><c:out value="${item.tickets.stati.descrizione}" /></td>
					<td><c:out value="${item.tickets.utentiByIdUtente.nome}" /> <c:out
						value="${item.tickets.utentiByIdUtente.cognome}" /></td>
					<td><fmt:formatDate pattern="dd/MM/yyyy"
						value="${item.tickets.dataUltimaModifica}" /></td>
					<td><c:out
						value="${item.tickets.utentiByIdUtenteUltimaModifica.nome}" /> <c:out
						value="${item.tickets.utentiByIdUtenteUltimaModifica.cognome}" /></td>
					<td><c:out value="${item.tickets.utentiByIdOwner.nome}" /> <c:out
						value="${item.tickets.utentiByIdOwner.cognome}" /></td>
					<td><c:if test="${not empty item.tickets.allegatis}">
						<a
							href="visualizzaListaAllegati.do?id=<c:out value="${item.tickets.idTicket }"/>"
							target="_blank">Visualizza</a>
					</c:if></td>
				</tr>
			</c:forEach>
			<table>
				<tr>
					<td align="right"><c:if test="${!currentPage.firstPage }">
						<a href="search.do?p=<c:out value='${prevPage }' />&action=prev">prev</a>
					</c:if> <c:if test="${!currentPage.firstPage && !currentPage.lastPage }">	
				|</c:if> <c:if test="${!currentPage.lastPage }">
						<a href="search.do?p=<c:out value='${nextPage }' />&action=next">next</a>
					</c:if></td>
					<td>Pagina <c:out value="${currentPage.page }" /> di <c:out
						value="${currentPage.pagineTotali}" /></td>
				</tr>
			</table>
		</table>
	</c:when>
	<c:otherwise>
		Nessun ticket trovato
	</c:otherwise>
</c:choose>
<c:if test="${not empty storico }">
	<table width="100%" border="1">
		<c:forEach items="${storico}" var="item">
			<c:choose>
				<c:when test="${item.prossimaAzione==null }">
					<tr>
						<td width="10%"><fmt:formatDate value="${item.dataModifica }"
							pattern="dd/MM/yyyy" /></td>
						<td width="80%"><c:out value="${item.descrizione}"></c:out></td>
						<td width="10%"><c:if test="${not empty item.allegatis }">
							<a
								href="visualizzaListaAllegati.do?ids=<c:out value="${item.idStorico }"/>"
								target="_blank">Vedi allegati</a>
						</c:if></td>
					</tr>
				</c:when>
				<c:otherwise>
					<tr>
						<td width="10%"><fmt:formatDate value="${item.dataModifica }"
							pattern="dd/MM/yyyy" /></td>
						<td width="80%"><c:out value="${item.prossimaAzione}"></c:out></td>
						<td width="10%"><c:if test="${not empty item.allegatis }">
							<a
								href="visualizzaListaAllegati.do?ids=<c:out value="${item.idStorico }"/>"
								target="_blank">Vedi allegati</a>
						</c:if></td>
					</tr>
				</c:otherwise>
			</c:choose>
		</c:forEach>
	</table>
</c:if>
</body>
</html>
<%
	} catch (Exception e) {
		e.printStackTrace();
	}
%>
